<template>
	<view class="my-same-trade-lists-area">
		<view class="my-same-trade-item u-padding-30" v-for="(v,index) in listDatas" :key="index">
			<view class="u-flex u-padding-bottom-10">
				<view class="u-flex u-flex-1">
					<text class="md">{{v.create_time}}</text>
					<text class="md u-padding-left-10 u-padding-right-10">发布</text>
				<u-tag text="审核中" type="warning" size="mini" v-if="v.audit_status == 0" />
				<u-tag text="审核失败" type="error" size="mini" v-if="v.audit_status == 2" />
				</view>
			<u-icon name="more-dot-fill" color="#666666" size="30" class="more-icon" v-if="v.audit_status != 0"
				@click="onActionSheet(v)"></u-icon>
			</view>
			
			<u-icon  :label="v.type_desc" size="30" name="tags-fill" color="#66a6ff" label-color="#66a6ff"></u-icon>
			
			<view v-if="v.type == 1" class="area-bg u-border-radius-10 u-margin-top-15 u-padding-20">
				<view>
					<text class="bold">产品名称 :</text>
					<text class="u-font-weight-500 u-padding-left-10">{{v.product_name||''}}</text>
				</view>
				<view class="u-margin-top-15">
					<text class="bold">产品月息 :</text>
					<text class="u-font-weight-500 u-padding-left-10">{{v.interests||''}}</text>
				</view>
				<view class="u-margin-top-15">
					<text class="bold">产品额度 :</text>
					<text class="u-font-weight-500 u-padding-left-10">{{v.quota||0}}万</text>
				</view>
				<view>
					<view class="bold u-margin-top-15">
						产品优势描述 :
					</view>
					<view class="nr u-margin-top-15">
						{{v.describe||''}}
					</view>
				</view>
			</view>
			<view class="area-bg u-border-radius-10 u-margin-top-15 u-padding-20">
				<view class="bold u-padding-right-10">合作需求 :</view>
				<view class="u-padding-top-10">
					{{v.demand||''}}
				</view>
			</view>
			
			<view class="u-flex  u-color-666666 xs u-margin-top-25 u-padding-bottom-25">
				<view class="u-flex-1"></view>
				<u-icon :label="v.look_count" name="eye" size="24" label-size="24" class="u-padding-right-30"></u-icon>
				<u-icon :label="v.like_count" name="thumb-up" size="24" label-size="24" class="u-padding-right-30"></u-icon>
				<!-- <u-icon :label="33" name="chat" size="24" label-size="24"></u-icon> -->
			</view>
		</view>
		
		<u-empty v-if="listDatas.length <= 0" class="u-padding-top-50 u-padding-bottom-50" text="暂无数据"
			mode="list"></u-empty>
		
	</view>
</template>

<script>
	import {
		queryCooperationListsMy,
		queryCooperationListsDel
	} from '@/yixu/api/network_square'
	import {
		loadingType
	} from "@/utils/type";
	import {
		loadingFun
	} from "@/utils/tools"
	export default {
		data() {
			return {
				page: 1,
				listDatas: [],
				initStatus: false,
				loadingStatus: loadingType.LOADING,
			}
		},
		props: {
			
		},
		created() {
			this.queryListsDatas()
		},
		methods: {
			onActionSheet(item) {
				let _this = this;
				uni.showActionSheet({
					itemList: [
						'编辑',
						'删除',
					],
					success(res) {
						// console.log(res);
						if (res.tapIndex == 0) {
							uni.setStorageSync('cooperation_item', item);
							uni.navigateTo({
								url: `/yixu/pages/publish/cooperation?id=${item.id}&edit=1`
							})
						}
						
						if (res.tapIndex == 1) {
							uni.showModal({
								title: '提示',
								content: '确认删除吗？',
								async success(res) {
									if (res.confirm) {
										try {
											await queryCooperationListsDel({
												id: item.id
											});
											_this.clearDatas();
											_this.queryListsDatas();
										} finally {
			
										}
									}
								}
							})
						}
					}
				})
			},
			clearDatas() {
				this.page = 1;
				this.listDatas = [];
				this.loadingStatus = loadingType.LOADING;
			},
			queryListsDatas() {
				let requestParams = {
			
				}
				let {
					page,
					listDatas,
					loadingStatus
				} = this;
				loadingFun(queryCooperationListsMy, page, listDatas, loadingStatus, requestParams).then(res => {
					if (res) {
						this.page = res.page;
						this.listDatas = res.dataList
						this.loadingStatus = res.status
						console.log(listDatas)
						if(!this.initStatus){
							this.$emit('initComplete')
							this.initStatus = true
						}
						
					}
				})
			}
		}
	}
</script>


<style lang="scss">
	.my-same-trade-item{
		border-bottom: 2rpx solid #F5F5F5;
		
		&:last-child{
			border-bottom-color: transparent;
		}
	}
	
	.more-icon{
		transform: rotate(90deg);
	}
	
	.area-bg{
		background: #F7F7F7;
	}
</style>